package Utilidades;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import vista.VentanaGeneral;

/**
 *
 * @author jjcamacho
 */
public class VideoWall {

    private List<Celda> videoWall;

    public VideoWall(Dimension size) {
        videoWall = new ArrayList<Celda>();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        byte filas = (byte) (screenSize.getHeight() / size.getHeight());
        byte columnas = (byte) (screenSize.getWidth() / size.getWidth());

        for (byte i = 0; i < filas; i++) {
            for (byte j = 0; j < columnas; j++) {
                int x = (int) (size.getWidth() * j);
                int y = (int) (size.getHeight() * i);
                videoWall.add(new Celda(new Point(x, y)));
            }
        }
    }

    public Celda obtenerCelda() {
        Celda celda = null, c = null;
        Boolean enc = false;
        Iterator it = this.videoWall.iterator();
        while (it.hasNext() && !enc) {
            c = (Celda) it.next();
            if (c.isLibre()) {
                c.setLibre(false);
                celda = c;
                enc = true;
            }
        }
        return celda;
    }

    public void liberarCelda(VentanaGeneral ventana){

    }
}
